package com.xmkj.bearuser.member;

import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.TextView;

import com.common.adapter.helper.IRecyclerViewHelper;
import com.common.mvp.BaseMvpActivity;
import com.common.mvp.BasePresenter;
import com.common.utils.SizeUtils;
import com.common.widget.DividerDecoration.MarginDecoration;
import com.common.widget.recyclerview.refresh.recycleview.XRecyclerView;
import com.xmkj.bearuser.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ChuJiOrderListActivity extends BaseMvpActivity {
    public static final String TYPE = "type";
    @BindView(R.id.tv1)
    TextView tv1;
    @BindView(R.id.tv2)
    TextView tv2;
    @BindView(R.id.tv3)
    TextView tv3;
    @BindView(R.id.tv4)
    TextView tv4;
    @BindView(R.id.tv5)
    TextView tv5;
    @BindView(R.id.tv6)
    TextView tv6;
    @BindView(R.id.recyclerview)
    XRecyclerView recyclerview;
    private int type;
    List<String> bean = new ArrayList<>();
    private ChuZhiAdapter adapter;

    @Override
    protected BasePresenter createPresenterInstance() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_ji_chu_order;
    }

    @Override
    protected void onViewCreated() {

    }

    @Override
    protected void doLogicFunc() {
        bean.add("");
        bean.add("");
        bean.add("");
        bean.add("");
        bean.add("");
        System.out.println("tyep"+ type);
        if(type==1){
            tv1.setText("日期时间");
            tv2.setText("订单编号");
            tv3.setText("件数");
            tv4.setText("金额");
            tv5.setText("赠送积分");
            tv6.setText("抵扣积分");
        }else if(type==2){
            tv6.setVisibility(View.GONE);
            tv1.setText("日期");
            tv2.setText("初始额");
            tv3.setText("储值变化");
            tv4.setText("备注");
            tv5.setText("余额");
        }else if(type==3){
            tv6.setVisibility(View.GONE);
            tv1.setText("日期时间");
            tv2.setText("积分初始额");
            tv3.setText("积分变化");
            tv4.setText("备注");
            tv5.setText("积分余额");
        }
        gotoHttpRep();
        setRecyclerView();
    }

    private void setRecyclerView() {
        IRecyclerViewHelper.init().setRecycleLineLayout(context, LinearLayoutManager.VERTICAL, recyclerview);
        recyclerview.addItemDecoration(new MarginDecoration(LinearLayoutManager.VERTICAL, (int) SizeUtils.dp2px(context, 1)));
        recyclerview.setHasFixedSize(true);
        recyclerview.setRefreshing(false);
//        recyclerview.addItemDecoration(new MarginDecoration(LinearLayoutManager.HORIZONTAL, (int) SizeUtils.dp2px(context, 1)));
//        recyclerview.addItemDecoration(new MarginDecoration(LinearLayoutManager.VERTICAL, (int) SizeUtils.dp2px(context, 1)));
        recyclerview.setLoadMoreEnabled(true);
        adapter = new ChuZhiAdapter(context, bean,type);
//        adapter.setOnItemClickSeclect(this);
        recyclerview.setAdapter(adapter);
        recyclerview.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                mPageIndex = 1;
                mIsRefreshOrLoadMore = 0;
                gotoHttpRep();
            }

            @Override
            public void onLoadMore() {
                if (mIsHasNoData) {
                    recyclerview.loadMoreComplete();
                    recyclerview.setNoMore(true);
                    return;
                }
                mPageIndex++;
                mIsRefreshOrLoadMore = 1;
                gotoHttpRep();
            }
        });
    }

    private void gotoHttpRep() {
    }

    @Override
    protected void setNavigation() {
        type = getIntent().getIntExtra(TYPE, Integer.MAX_VALUE);
        switch (type) {
            case 1:
                setNavigationBack("用户订单");
                break;
            case 2:
                setNavigationBack("储值详情");
                break;
            case 3:
                setNavigationBack("积分详情");
                break;
        }
    }


    @Override
    public void bindKnife() {
        ButterKnife.bind(this);
    }
}
